package cn.qayy.utils;

import java.util.Properties;
import java.util.Set;

/***
 *@author jobs1127
 *
 *
 */
public class PropertiesUtil {
    private static Properties pops = new Properties();
    private PropertiesUtil(){}
    static {
        try {
            /***
             * classLoader是从类路径下寻找资源文件
             */
            //pops.load(PropertiesUtil.class.getClassLoader().getResourceAsStream("mgr-province.properties"));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /***
     * 根据key获取字符串value
     * @param key
     * @return
     */
    public static String getValue(String key){
        return pops.get(key)==null?null:pops.get(key).toString();
    }

    /**
     * 根据key获取数组value
     * @param key
     * @return
     */
    public static String[] getValues(String key){
        String s = (String)pops.get(key);
        if(s != null){
            return s.split(",");
        }
        return null;
    }

    /***
     * 获取配置文件中所有的key的集合
     * @return
     */
    public static Set getKeySet(){
        return pops.keySet();
    }
}
